package com.ruoyi.web.controller.ring;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.ring.domain.RingVoiceRecord;
import com.ruoyi.ring.service.IRingVoiceRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 语音转写记录Controller
 * 
 * @author liuwp
 * @date 2025-10-24
 */
@RestController
@RequestMapping("/ring/ring_voice_record")
public class RingVoiceRecordController extends BaseController
{
    @Autowired
    private IRingVoiceRecordService ringVoiceRecordService;

    /**
     * 查询语音转写记录列表
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_voice_record:list')")
    @GetMapping("/list")
    public TableDataInfo list(RingVoiceRecord ringVoiceRecord)
    {
        startPage();
        List<RingVoiceRecord> list = ringVoiceRecordService.selectRingVoiceRecordList(ringVoiceRecord);
        return getDataTable(list);
    }

    /**
     * 导出语音转写记录列表
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_voice_record:export')")
    @Log(title = "语音转写记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RingVoiceRecord ringVoiceRecord)
    {
        List<RingVoiceRecord> list = ringVoiceRecordService.selectRingVoiceRecordList(ringVoiceRecord);
        ExcelUtil<RingVoiceRecord> util = new ExcelUtil<RingVoiceRecord>(RingVoiceRecord.class);
        util.exportExcel(response, list, "语音转写记录数据");
    }

    /**
     * 获取语音转写记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_voice_record:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ringVoiceRecordService.selectRingVoiceRecordById(id));
    }

    /**
     * 新增语音转写记录
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_voice_record:add')")
    @Log(title = "语音转写记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RingVoiceRecord ringVoiceRecord)
    {
        return toAjax(ringVoiceRecordService.insertRingVoiceRecord(ringVoiceRecord));
    }

    /**
     * 修改语音转写记录
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_voice_record:edit')")
    @Log(title = "语音转写记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RingVoiceRecord ringVoiceRecord)
    {
        return toAjax(ringVoiceRecordService.updateRingVoiceRecord(ringVoiceRecord));
    }

    /**
     * 删除语音转写记录
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_voice_record:remove')")
    @Log(title = "语音转写记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ringVoiceRecordService.deleteRingVoiceRecordByIds(ids));
    }
}
